#include<iostream>
#include<algorithm>
using namespace std;
const int MAX = 510;
const int INT_MAX = (unsigned)(-1) >> 1;
int N,M,C1,C2;
int teams[MAX], roads[MAX][MAX];
int visited[MAX]={0},dist[MAX], rescue[MAX]={0}, num[MAX]={0};
int main(int argc, char const *argv[])
{
    freopen("test.txt","r",stdin);
    cin>>N>>M>>C1>>C2;
    for(int i =0;i<N;++i)cin>>teams[i];
    fill(roads[0],roads[0]+MAX*MAX,INT_MAX);
    for(int i=0;i<M;++i)
    {
        int n1,n2,L;cin>>n1>>n2>>L;
        roads[n1][n2] = roads[n2][n1] = L;
    }

    fill(dist,dist+N,INT_MAX);
    
    dist[C1]=0; rescue[C1]=teams[C1]; num[C1]=1;//visited[C1]=1; 
    for(int _ = 0;_<N;++_)
    {
        int u = -1, min_dist=INT_MAX;
        for(int i = 0;i<N;++i)
        {
            if(!visited[i] && dist[i] < min_dist)
            {
                u = i; min_dist = dist[i];
            }
        }
        visited[u] = 1; 
        // update all unvistied and connected to u
        for(int i = 0;i<N;++i)
        {
            if(roads[u][i] < INT_MAX && !visited[i])
            {
                if(dist[u] + roads[u][i] < dist[i])
                {
                    dist[i] = dist[u] + roads[u][i];
                    num[i] = num[u]; rescue[i] = rescue[u]+teams[i];
                }
                else if(dist[u] + roads[u][i] == dist[i])
                {
                    num[i] += num[u]; 
                    rescue[i] = rescue[i] > rescue[u]+teams[i] ? rescue[i]:rescue[u]+teams[i];
                }
            }
        }
    }

    cout<<num[C2]<<" "<<rescue[C2];

    return 0;
}
